package com.distributer.policy.thread;

import java.util.concurrent.ArrayBlockingQueue;

import com.distributer.policy.request.Request;

/**
 * 保单请求处理线程
 * @author Administrator
 *
 */
public class PolicyRequestHandlerTask implements Runnable{

	private ArrayBlockingQueue<Request> requestQueue;
	
	public PolicyRequestHandlerTask(ArrayBlockingQueue<Request> requestQueue){
		this.requestQueue = requestQueue;
	}
	
	public void run() {
		while (!Thread.currentThread().isInterrupted()) {
			if (requestQueue.isEmpty()) {
				try {
					Thread.sleep(10);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				try {
					Request request = requestQueue.take();
					request.prosess();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
